﻿Imports System.Data.SqlClient

Public Class clsLiquidadores
    Private mintIdEmpleado As Integer
    Private mstrNombreCompleto As String
    Private mstrBaseDatos As String
    Private mstrEstadoEmpleado As String
    Private mstrCodigo As String

    Public Property IdEmpleado() As Integer
        Get
            Return mintIdEmpleado
        End Get
        Set(ByVal value As Integer)
            mintIdEmpleado = value
        End Set
    End Property
    Public Property NombreCompleto() As String
        Get
            Return mstrNombreCompleto
        End Get
        Set(ByVal value As String)
            mstrNombreCompleto = value
        End Set
    End Property
    Public Property BaseDatos() As String
        Get
            Return mstrBaseDatos
        End Get
        Set(ByVal value As String)
            mstrBaseDatos = value
        End Set
    End Property
    Public Property EstadoEmpleado() As String
        Get
            Return mstrEstadoEmpleado
        End Get
        Set(ByVal value As String)
            mstrEstadoEmpleado = value
        End Set
    End Property
    Public Property Codigo() As String
        Get
            Return mstrCodigo
        End Get
        Set(ByVal value As String)
            mstrCodigo = value
        End Set
    End Property
    Public Sub New()
        mintIdEmpleado = 0
        mstrNombreCompleto = ""
        mstrBaseDatos = ""
        mstrEstadoEmpleado = ""
        mstrCodigo = ""


    End Sub
    Public Sub Insertar()
        Dim sql As String = "Insert Into Liquidadores (" & _
                            "IdEmpleado," & _
                            "NombreCompleto," & _
                            "BaseDatos," & _
                            "EstadoEmpleado, " & _
                            "Codigo)" & _
                            "VALUES (" & _
                            "@IdEmpleado," & _
                            "@NombreCompleto," & _
                            "@BaseDatos," & _
                            "@EstadoEmpleado," & _
                            "@Codigo)"


        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = InitialConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("IdEmpleado", mintIdEmpleado)
        Command.Parameters.AddWithValue("NombreCompleto", mstrNombreCompleto)
        Command.Parameters.AddWithValue("BaseDatos", mstrBaseDatos)
        Command.Parameters.AddWithValue("EstadoEmpleado", mstrEstadoEmpleado)
        Command.Parameters.AddWithValue("Codigo", mstrCodigo)

        cnConn.Open()
        Dim RowsAffected As Integer
        Try
            RowsAffected = Command.ExecuteNonQuery
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Aviso")
        End Try

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible insertar el liquidador", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If
    End Sub
End Class
